package com.contact;

import java.util.ArrayList;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import com.adpter.IyrUserListAdapter;
import com.android.ocean.util.common.StringUtil;
import com.android.ocean.util.common.TranHelper;
import com.common.method.FromFlag;
import com.matang.R;
import com.modle.User;
import com.util.AppUtil;

/**
 * 
 * @author ZhuwI艺人列表
 * 
 */
public class YrListActivity extends BaseActivity implements OnClickListener {
	ListView listView;
	ArrayList<User> userList;
	IyrUserListAdapter adapter;
	public static YrListActivity instance;

	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		setContentView(R.layout.act_yrlist);
		instance = this;
		init();
	}

	void init() {
		mContext = YrListActivity.this;
		findViews();
		initPaneData();

	}

	public void initPaneData() {
		super.initPaneData();
		header.headTitleTv.setText("好友列表");
		userList = (ArrayList<User>) getIntent().getSerializableExtra(
				"userList");
		fillList();
	}

	@Override
	protected void findViews() {
		super.findViews();
		listView = (ListView) findViewById(R.id.listView);
		listView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int pos,
					long arg3) {
				Bundle b = new Bundle();
				b.putSerializable("fUserID", userList.get(pos));
				b.putInt("FromFlag", FromFlag.USER_SIMPLEINFO_YRLIST);
				TranHelper.toAct(mContext, UserSimpleInfoActivity.class, b);

			}
		});

	}

	void fillList() {
		if (StringUtil.isListNull(userList)) {
			AppUtil.tsMsg(mContext, "无数据...");
		} else {
			adapter = new IyrUserListAdapter(userList, mContext);
			listView.setAdapter(adapter);

		}

	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {

		}

	}

}
